﻿#region Namespace References

using System;
using System.Collections;
using System.Collections.Generic;
using DynConDevCorp.OpenArch.SmartData.Core;
using DynConDevCorp.OpenArch.SmartData.Interfaces;
using DynConDevCorp.OpenArch.SmartData.Interfaces.EventArgClasses;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using UnitTest.DynConDevCorp.OpenArch.SmartData.Unit_Tests;

#endregion

namespace UnitTest.DynConDevCorp.OpenArch.SmartData
{
    /// <summary>
    ///This is a test class for SmartField_UnitTests and is intended
    ///to contain all SmartField_UnitTests Unit Tests
    ///</summary>
    [TestClass]
    public class SmartEntityCollection_UnitTests
    {
        #region Public Instance Properties

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get { return testContextInstance; }
            set { testContextInstance = value; }
        }

        #endregion

        #region Public Instance Methods

        [TestMethod]
        public void Add_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const ISmartEntity entity = null;
            target.Add(entity);
        }

        [TestMethod]
        public void Add_UnitTest1()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const SmartEntity entity = null;
            target.Add(entity);
        }

        [TestMethod]
        public void Clear_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            target.Clear();
        }

        [TestMethod]
        public void CollectionClassCategory_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            CollectionClassCategory actual = target.CollectionClassCategory;
            Assert.AreEqual(CollectionClassCategory.Entity, actual);
        }

        [TestMethod]
        public void Commit_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            target.Commit();
        }

 
        [TestMethod]
        public void Contains_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const TestSmartEntity entity = null;
            const bool expected = false;
            bool actual = target.Contains(entity);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void ContainsField_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            string fieldName = string.Empty;
            const bool expected = false;
            bool actual = target.ContainsField(fieldName);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void Count_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            ISmartField<int> actual = target.Count;
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        public void DataType_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            Type actual = target.DataType;
            Assert.IsNotNull(actual);
        }


         // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup]
        //public void MyTestCleanup()
        //{
        //}
        //

        [TestMethod]
        public void DisplayFormatter_UnitTest()
        {
            DisplayFormatter_UnitTestHelper<int>();
        }

        /// <summary>
        ///A test for DisplayFormatter
        ///</summary>
        public void DisplayFormatter_UnitTestHelper<DATA_TYPE>()
            where DATA_TYPE : IComparable<DATA_TYPE>
        {
            SmartField<DATA_TYPE> target = new SmartField<DATA_TYPE>();
            const ISmartDisplayFormatter<DATA_TYPE> expected = null;
            target.DisplayFormatter = expected;
            ISmartDisplayFormatter<DATA_TYPE> actual = target.DisplayFormatter;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotSupportedException))]
        public void DisplayValue_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            string actual = target.DisplayValue;
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        public void EnableTrackChanges_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
             target.EnableTrackChanges(true);
            target.EnableTrackChanges(false);
        }

        [TestMethod]
        public void EntityID_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            Guid actual = target.EntityID;
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        public void EntityType_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            Type actual = target.EntityType;
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        public void FieldCount_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            int actual = target.FieldCount;
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        public void FieldNames_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            IList<string> actual = target.FieldNames;
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void Fields_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            ISmartFieldKeyedCollection<string, ISmartField> actual = target.Fields;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for FieldValueChanged()
        ///</summary>
        [TestMethod]
        public void FieldValueChanged_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            target.FieldValueChanged += target_FieldValueChanged;
            m_FieldValueChanged_Fired = false;
            target.Count.Value = 123;
            Assert.IsTrue(m_FieldValueChanged_Fired);
            target.FieldValueChanged -= target_FieldValueChanged;
        }

        [TestMethod]
        [ExpectedException(typeof(NotSupportedException))]
        public void FormattedDisplay_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            string formatString = string.Empty;
            const string expected = "123";
            string actual = target.FormattedDisplay(formatString);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void GetEntities_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            IEnumerable<TestSmartEntity> actual = target.GetEntities<TestSmartEntity>();
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        public void GetEntities_UnitTest1()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            IEnumerable<TestSmartEntity> actual = target.GetEntities();
            Assert.IsNotNull(actual);
        }

        public void GetEntities_UnitTestHelper<RETURN_ENTITY_TYPE>()
            where RETURN_ENTITY_TYPE : ISmartEntity
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const IEnumerable<RETURN_ENTITY_TYPE> expected = null;
            IEnumerable<RETURN_ENTITY_TYPE> actual = target.GetEntities<RETURN_ENTITY_TYPE>();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetEntity_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const int index = 0;
            SmartEntity actual = target.GetEntity(index);
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void GetEntity_UnitTest1()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const int index = 0;
            SmartEntity actual = target.GetEntity<SmartEntity>(index);
            Assert.IsNotNull(actual);
        }

        public void GetEntity_UnitTest1Helper<RETURN_ENTITY_TYPE>()
            where RETURN_ENTITY_TYPE : ISmartEntity
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const int index = 0;
            RETURN_ENTITY_TYPE expected = default(RETURN_ENTITY_TYPE);
            RETURN_ENTITY_TYPE actual = target.GetEntity<RETURN_ENTITY_TYPE>(index);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void GetEntity_UnitTest2()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            Guid identity = new Guid();
            const SmartEntity expected = null;
            SmartEntity actual = target.GetEntity(identity);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void GetEntity_UnitTest3()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            Guid identity = new Guid();
            const SmartEntity expected = null;
            SmartEntity actual = target.GetEntity<SmartEntity>(identity);
            Assert.AreEqual(expected, actual);
        }

        public void GetEntity_UnitTest3Helper<RETURN_ENTITY_TYPE>()
            where RETURN_ENTITY_TYPE : ISmartEntity
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            Guid identity = new Guid();
            RETURN_ENTITY_TYPE expected = default(RETURN_ENTITY_TYPE);
            RETURN_ENTITY_TYPE actual = target.GetEntity<RETURN_ENTITY_TYPE>(identity);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetEnumerator_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            IEnumerator actual = target.GetEnumerator();
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void GetFieldItem_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            TestSmartEntity actual = target.GetFieldItem <TestSmartEntity>(0);
            Assert.IsNotNull(actual);
        }

        public void GetFieldItem_UnitTestHelper<RETURN_TYPE>()
            where RETURN_TYPE : ISmartField
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const int index = 0;
            RETURN_TYPE expected = default(RETURN_TYPE);
            RETURN_TYPE actual = target.GetFieldItem<RETURN_TYPE>(index);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void GetFieldItems_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            IEnumerable<TestSmartEntity> actual = target.GetFieldItems<TestSmartEntity>();
            Assert.IsNotNull(actual);
        }

        public void GetFieldItems_UnitTestHelper<RETURN_TYPE>()
            where RETURN_TYPE : ISmartField
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const IEnumerable<RETURN_TYPE> expected = null;
            IEnumerable<RETURN_TYPE> actual = target.GetFieldItems<RETURN_TYPE>();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void GetItems_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            IEnumerable<TestSmartEntity> actual = target.GetItems<TestSmartEntity>();
            Assert.IsNotNull(actual);
        }

        public void GetItems_UnitTestHelper<RETURN_TYPE>()
            where RETURN_TYPE : class, ISmartBase
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const IEnumerable<RETURN_TYPE> expected = null;
            IEnumerable<RETURN_TYPE> actual = target.GetItems<RETURN_TYPE>();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void GetRawEnumerator_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            IEnumerator actual = target.RawEnumerator();
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void InputInhibited_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const bool expected = false;
            target.InputInhibited = expected;
            bool actual = target.InputInhibited.ToBoolean();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void InputParser_UnitTest()
        {
            InputParser_UnitTestHelper<int>();
        }

        /// <summary>
        ///A test for InputParser
        ///</summary>
        public void InputParser_UnitTestHelper<DATA_TYPE>()
            where DATA_TYPE : IComparable<DATA_TYPE>
        {
            SmartField<DATA_TYPE> target = new SmartField<DATA_TYPE>();
            const ISmartInputParser<DATA_TYPE> expected = null;
            target.InputParser = expected;
            ISmartInputParser<DATA_TYPE> actual = target.InputParser;
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotSupportedException))]
        public void InputValue_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            target.InputValue = "123";
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void IsDirty_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            PartialBoolean actual = target.IsDirty;
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        public void Item_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const string fieldName = "Count";
            ISmartField actual = target[fieldName];
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        public void ItemType_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            Type actual = target.ItemType;
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        public void MarkAsDirty_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            target.MarkAsDirty();
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void NewEntity_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const ISmartEntity expected = null;
            ISmartEntity actual = target.NewEntity();
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void NewEntity_UnitTest1()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            Guid identity = new Guid();
            const ISmartEntity expected = null;
            ISmartEntity actual = target.NewEntity(identity);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void OwningEntity_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            ISmartEntity actual = target.OwningEntity;
            Assert.IsNull(actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void PersistanceState_1_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const SmartPersistenceState expected = new SmartPersistenceState();
            target.PersistenceState = expected;
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void PersistanceState_2_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            SmartPersistenceState actual = target.PersistenceState;
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotSupportedException))]
        public void RawValue_1_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            object expected = 123;
            target.RawValue = expected;
        }

        [TestMethod]
        [ExpectedException(typeof(NotSupportedException))]
        public void RawValue_2_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            object actual = target.RawValue;
            Assert.IsNotNull(actual);
        }

        /// <summary>
        ///A test for RawValueChanged()
        ///</summary>
        [TestMethod]
        [ExpectedException((typeof (NotSupportedException)))]
        public void RawValueChanged_UnitTest()
        {
            ISmartField target = new TestSmartEntityCollection();
            target.RawValueChanged += target_RawValueChanged;
            m_RawValueChanged_Fired = false;
            target.RawValue = 123;
            Assert.IsTrue(m_RawValueChanged_Fired);
            target.RawValueChanged -= target_RawValueChanged;
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void ReadOnly_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            target.WriteLocked = true;
            Assert.IsTrue(target.WriteLocked.ToBoolean());
            target.WriteLocked = false;
            Assert.IsFalse(target.WriteLocked.ToBoolean());
        }

         [TestMethod]
        public void RegisterField_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const string fieldName = "DynamicCollectionField";
            ISmartField field = new SmartField<int>();
            ISmartField actual = target.RegisterField(fieldName, field);
            Assert.AreSame(field, actual);
        }

        [TestMethod]
        public void Remove_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const TestSmartEntity entity = null;
            const bool expected = false;
            bool actual = target.Remove(entity);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void RollBack_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            target.EnableTrackChanges(true);
            target.Rollback();
        }

        [TestMethod]
        public void SetOwningEntity_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            target.SetOwningEntity(null);
        }

        [TestMethod]
        public void SetRawFieldValue_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            const string fieldName = "Count";
            target.SetRawFieldValue(fieldName, -1);
        }

        /// <summary>
        ///A test for SmartField Constructor
        ///</summary>
        [TestMethod]
        public void SmartFieldConstructor_UnitTest()
        {
            ISmartField target = new TestSmartEntityCollection();
            Assert.IsNotNull(target);
        }

        [TestMethod]
        public void SmartFieldConstructor_UnitTest1()
        {
            SmartFieldConstructor_UnitTest1Helper<int>();
        }

        /// <summary>
        ///A test for SmartField`1 Constructor
        ///</summary>
        public void SmartFieldConstructor_UnitTest1Helper<DATA_TYPE>()
            where DATA_TYPE : IComparable<DATA_TYPE>
        {
            SmartField<DATA_TYPE> target = new SmartField<DATA_TYPE>();
            Assert.IsNotNull(target);
        }

        [TestMethod]
        public void TestSmartEntityCollectionConstructor_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for ToString()
        ///</summary>
        [TestMethod]
        public void ToString_UnitTest()
        {
            ISmartField target = new TestSmartEntityCollection();
            String actual = target.ToString();
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void TrackingChanges_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            PartialBoolean actual = target.TrackingChanges;
            Assert.IsNotNull(actual);
        }

        [TestMethod]
        [ExpectedException(typeof(NotImplementedException))]
        public void TryGetValue_UnitTest()
        {
            TestSmartEntityCollection target = new TestSmartEntityCollection();
            Guid id = new Guid();
            TestSmartEntity value;
            const TestSmartEntity valueExpected = null;
            const bool expected = false;
            bool actual = target.TryGetValue(id, out value);
            Assert.AreEqual(valueExpected, value);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod]
        public void Value_UnitTest()
        {
            Value_UnitTestHelper<int>();
        }

        /// <summary>
        ///A test for Value
        ///</summary>
        public void Value_UnitTestHelper<DATA_TYPE>()
            where DATA_TYPE : IComparable<DATA_TYPE>
        {
            SmartField<DATA_TYPE> target = new SmartField<DATA_TYPE>();
            DATA_TYPE expected = default(DATA_TYPE);
            target.Value = expected;
            DATA_TYPE actual = target.Value;
            Assert.AreEqual(expected, actual);
        }

        #endregion

        #region Private Instance Methods

        private void target_FieldValueChanged(object sender, FieldValueChangedEventArgs e)
        {
            m_FieldValueChanged_Fired = true;
        }


        private void target_RawValueChanged(object sender, ValueChangedEventArgs<object> e)
        {
            m_RawValueChanged_Fired = true;
        }

        #endregion

        #region Fields and Constants

        private bool m_FieldValueChanged_Fired;
        private bool m_RawValueChanged_Fired;

        private TestContext testContextInstance;

        #endregion

    }
}